package com.bittech.httpd.handler;

import com.bittech.httpd.common.HttpRequest;
import com.bittech.httpd.common.HttpResponse;
import com.bittech.httpd.core.HandlerAdapter;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Author: secondriver
 * Created: 2018/9/5
 */
public class IndexHandler extends HandlerAdapter {
    
    @Override
    public void doGet(HttpRequest request, HttpResponse response) {
        response.setContentType("text/html; charset=UTF-8");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        response.write("<h2>" + format.format(new Date()) + "</h2>");
        response.write("<p>以上信息由服务端动态生成，刷新网页，时间更新</p>");
        response.write("<hr/>");
        response.write("<p><a href='/about'>关于（动态接口）</a></p>");
        response.write("<p><a href='/index.html'>2048（静态页面）</a></p>");
        response.flush();
    }
}
